home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Draw Editor / Source / DrawEditor.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-11  |  13.0 KB  |  436 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        DrawEditor.h
  3.  
  4.     Contains:    Sample part editor class implementation
  5.  
  6.     Written by:    Dave Stafford
  7.     
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11. #ifndef _DRAWEDITOR_
  12. #define _DRAWEDITOR_
  13.  
  14. // -- DrawEditor Includes --
  15.  
  16. #ifndef _COMPILERDEFS_
  17. #include "CompDefs.h"
  18. #endif
  19.  
  20. #ifndef _DRAWEDITORGLOBALS_
  21. #include "DrawEditorGlobals.h"
  22. #endif
  23.  
  24. // -- OpenDoc Includes --
  25.  
  26. #ifndef _ODTYPES_
  27. #include <ODTypes.h>
  28. #endif
  29.  
  30. #ifndef _WINUTILS_
  31. #include <WinUtils.h>
  32. #endif
  33.  
  34. // -- Macintosh Includes --
  35.  
  36. #ifndef __TYPES__
  37. #include <Types.h>
  38. #endif
  39.  
  40. //==============================================================================
  41. // Forward Declarations
  42. //==============================================================================
  43.  
  44. // -- SOM
  45. class Environment;
  46.  
  47. // -- OpenDoc
  48.  
  49. class ODFacet;
  50. class ODFocusSet;
  51. class ODFrame;
  52. class ODMenuBar;
  53. class ODShape;
  54. class ODStorageUnit;
  55. class ODWindow;
  56. class ODSession;
  57. class ODDraft;
  58.  
  59. // -- DrawEditor
  60.  
  61. class CShape;
  62. class CSelection;
  63. class CCommand;
  64. class CCloneInfo;
  65. class CFrameList;            // Sample Code List Object
  66. class COrderedList;            // SampleCode Utility List Object
  67. class CPublishLink;
  68. class CSubscribeLink;
  69. class CPartContent;
  70.  
  71. //==============================================================================
  72. // DrawEditor
  73. //==============================================================================
  74. class DrawEditor {
  75.     
  76.       //========================
  77.     public:
  78.     
  79.     DrawEditor();
  80.     ~DrawEditor();
  81.     
  82.     // -- Initialization --
  83.     
  84.     void        InitPart(Environment* ev, ODStorageUnit* storageUnit,
  85.                                         ODPart* partWrapper);
  86.     void        InitPartFromStorage(Environment* ev, ODStorageUnit* storageUnit,
  87.                                         ODPart* partWrapper);
  88.     
  89.     // -- Accessors --
  90.     ODBoolean    IsReadOnly();
  91.  
  92.     ODLinkStatus GetLinkStatus() const;
  93.     ODValueType    GetEditorKind() const;
  94.     ODSession*    GetSession(Environment* ev) const;
  95.     ODDraft*    GetDraft(Environment* ev) const;
  96.     ODPart*     GetODPart() const;
  97.     
  98.     
  99.     COrderedList* GetShapeList() const;
  100.     
  101.     ODFacet*    GetRootFacetOfActiveWindow(Environment* ev) const;
  102.     COrderedList* GetEmbeddedFrames() const;
  103.     ODFrame*     GetFirstSourceFrame (Environment* ev);
  104.     COrderedList* GetContentDisplayFrames(Environment* ev) const;
  105.     ODFrame*     GetANYFrame(Environment* ev) const;
  106.     
  107.     ODULong        GetGroupCount() const;
  108.     ODULong        GetNewGroupID();
  109.     
  110.     ODSShort    GetDocumentWidth();
  111.     ODSShort    GetDocumentHeight();
  112.     void        SetDocumentWidth( ODSShort width );
  113.     void        SetDocumentHeight( ODSShort height );
  114.     
  115.     // -- Storage --
  116.     
  117.     void        SetDirty(Environment* ev);
  118.     
  119.     void        Release(Environment* ev);
  120.     void        ReleaseAll(Environment* ev);
  121.     ODSize        Purge(Environment* ev, ODSize size);
  122.     void        Externalize(Environment* ev);
  123.     void        ClonePartInfo( Environment*            ev,
  124.                                 ODDraftKey            key,
  125.                                   ODInfoType            partInfo,
  126.                                 ODStorageUnitView*    storageUnitView,
  127.                                 ODFrame*            scopeFrame );
  128.                                 
  129.     void        CloneInto(Environment* ev, ODDraftKey key,
  130.                                         ODStorageUnit* destinationSU,
  131.                                         ODFrame* scopeFrame);
  132.     void        WritePartInfo(Environment* ev, ODInfoType partInfo,
  133.                                         ODStorageUnitView* storageUnitView);
  134.     ODInfoType    ReadPartInfo(Environment* ev, ODFrame* frame,
  135.                                         ODStorageUnitView* storageUnitView);
  136.     
  137.     void        ExternalizeKinds(Environment* ev, ODTypeList* kindset);
  138.     void        ChangeKind(Environment* ev, ODType kind);
  139.     
  140.     // -- Promises --
  141.     void        FulfillPromise(Environment* ev, ODStorageUnitView* promiseSUView);
  142.     
  143.     // -- Layout --
  144.     
  145.     void        DisplayFrameAdded(Environment* ev, ODFrame* frame);
  146.     void        DisplayFrameRemoved(Environment* ev, ODFrame* frame);
  147.     void        DisplayFrameClosed(Environment* ev, ODFrame* frame);
  148.     void        DisplayFrameConnected(Environment* ev, ODFrame* frame);
  149.     void        AttachSourceFrame(Environment* ev, ODFrame* frame,
  150.                                         ODFrame* sourceFrame);
  151.     void        ViewTypeChanged(Environment* ev, ODFrame* frame);
  152.     void        FrameShapeChanged(Environment* ev, ODFrame* frame);
  153.     ODID        Open(Environment* ev, ODFrame* frame);
  154.     ODWindow*    AcquireFramesWindow(Environment*    ev, ODFrame* frame);
  155.         
  156.     // -- Imaging --
  157.     
  158.     void        Draw(Environment* ev, ODFacet* facet, ODShape* invalidShape);
  159.     void        GeometryChanged(Environment* ev, ODFacet* facet,
  160.                                         ODBoolean clipShapeChanged,
  161.                                         ODBoolean externalTransformChanged);
  162.     void        HighlightChanged(Environment* ev, ODFacet* facet);
  163.     void        FacetAdded(Environment* ev, ODFacet* facet);
  164.     void        FacetRemoved(Environment* ev, ODFacet* facet);
  165.     
  166.     // -- Activation --
  167.     
  168.     ODBoolean    BeginRelinquishFocus(Environment* ev, ODTypeToken focus,
  169.                                         ODFrame* ownerFrame,
  170.                                         ODFrame* proposedFrame);
  171.     void        CommitRelinquishFocus(Environment* ev, ODTypeToken focus,
  172.                                         ODFrame* ownerFrame,
  173.                                         ODFrame* proposedFrame);
  174.     void        AbortRelinquishFocus(Environment* ev, ODTypeToken focus,
  175.                                         ODFrame* ownerFrame,
  176.                                         ODFrame* proposedFrame);
  177.     void        FocusAcquired(Environment* ev,ODTypeToken focus,
  178.                                         ODFrame* ownerFrame);
  179.     void        FocusLost(Environment* ev,ODTypeToken focus,
  180.                                         ODFrame* ownerFrame);
  181.     
  182.     void        RelinquishAllFoci(Environment* ev, ODFrame* frame);
  183.     
  184.     void        PartActivated( Environment*    ev, ODFrame*    frame );
  185.     
  186.     // -- Event Handling --
  187.     
  188.     ODBoolean    HandleEvent(Environment* ev, ODEventData* event,
  189.                                         ODFrame* frame, ODFacet* facet,
  190.                                         ODEventInfo* eventInfo);
  191.     void        AdjustMenus(Environment* ev, ODFrame* frame);
  192.     
  193.     
  194.     // -- Drag & Drop --
  195.     void            DropCompleted(Environment *ev, ODPart* part, ODDropResult result);
  196.     ODDragResult    DragEnter(Environment *ev, 
  197.                             ODDragItemIterator* dragInfo, 
  198.                             ODFacet* facet, 
  199.                             ODPoint*  where);
  200.     ODDragResult    DragWithin(Environment *ev, 
  201.                             ODDragItemIterator* dragInfo, 
  202.                             ODFacet* facet, 
  203.                             ODPoint*  where);
  204.     void            DragLeave(Environment *ev, 
  205.                             ODFacet* facet, 
  206.                             ODPoint*  where);
  207.     ODDropResult    Drop(Environment *ev, 
  208.                             ODDragItemIterator* dragInfo, 
  209.                             ODFacet* facet, 
  210.                             ODPoint*  where);
  211.     
  212.     
  213.     // -- Commands --
  214.     void            ExecuteCommand(Environment *ev, CCommand* command);
  215.     void            UndoAction(Environment *ev, ODActionData* actionState);
  216.     void            RedoAction(Environment *ev, ODActionData* actionState);
  217.     void            DisposeActionState(Environment *ev, 
  218.                                     ODActionData* actionState,
  219.                                     ODDoneState doneState);
  220.     // Embedding        
  221.     ODShape*         AdjustBorderShape(Environment *ev, 
  222.                             ODFacet *embeddedFacet, ODShape* borderShape);
  223.     void             InvalidateActiveBorder(Environment *ev, ODFrame *frame);
  224.                             
  225.     void             ClipEmbeddedFacets(Environment *ev, ODFrame* containingFrame);
  226.     void             ClipEmbeddedFacets(Environment *ev, ODFacet *containingFacet);
  227.     void             RemoveEmbeddedFrame(Environment *ev, ODFrame* embeddedFrame);
  228.     ODShape*        RequestFrameShape(Environment *ev, ODFrame* embeddedFrame,
  229.                                         ODShape* frameShape);
  230.     ODFrame*         RequestEmbeddedFrame(Environment* ev,
  231.                                             ODFrame* containingFrame, 
  232.                                             ODFrame* baseFrame,
  233.                                             ODShape* frameShape,
  234.                                             ODPart* embedPart,
  235.                                             ODTypeToken viewType,
  236.                                             ODTypeToken presentation,
  237.                                             ODBoolean isOverlaid);
  238.     void             UsedShapeChanged(Environment* ev, ODFrame* embeddedFrame);
  239.                     
  240.     CShape*            ShapeForFrame(Environment* ev, ODFrame* embeddedFrame);
  241.     
  242.     // Linking    OpenDoc API
  243.     void             EmbeddedFrameUpdated(Environment* ev, ODFrame* frame, ODUpdateID updateID);
  244.     ODLinkSource*    CreateLink(Environment *ev, ODByteArray* data);
  245.     
  246.     // Linking  Internal support
  247.     void            SetPendingPublish(CPublishLink *link);
  248.     void             SetPendingDragPublish(CPublishLink *link);
  249.     void            DeletePendingPublish(Environment* ev);
  250.     void            AddPublishLink(CPublishLink *link);
  251.     void RemovePublishLink(Environment* ev, CPublishLink *link);
  252.  
  253.       //========================
  254.     protected:
  255.     
  256.     // -- Initialization --
  257.     
  258.     void        Initialize(Environment* ev);
  259.     void        LoadMenus(Environment* ev);
  260.     
  261.     // -- Storage --
  262.     
  263.     void        CheckAndAddProperties(Environment* ev,
  264.                                         ODStorageUnit* storageUnit);
  265.     void        CleanseContentProperty(Environment* ev,
  266.                                         ODStorageUnit* storageUnit);
  267.     void        InternalizeStateInfo(Environment* ev,
  268.                                         ODStorageUnit* storageUnit);
  269.     void        InternalizeContent(Environment* ev,
  270.                                         ODStorageUnit* storageUnit);
  271.     void        ExternalizeStateInfo( Environment*        ev,
  272.                                        ODStorageUnit*    storageUnit,
  273.                                        CCloneInfo*        info);
  274.     void        ExternalizeContent( Environment*        ev,
  275.                                      ODStorageUnit*        storageUnit,
  276.                                      CCloneInfo*        cloneInfo );    
  277.     
  278.     // -- Event Handling --
  279.     
  280.     ODBoolean    HandleMenuEvent(Environment* ev, ODEventData* event,
  281.                                            ODFrame* frame);
  282.     ODBoolean    HandleMouseEvent(Environment* ev, ODEventData* event,
  283.                                         ODFacet* facet, ODEventInfo* eventInfo);
  284.     ODBoolean    HandleWindowEvent(Environment* ev, ODEventData* event,
  285.                                            ODFrame* frame);
  286.     void        HandleMouseDown( Environment*    ev,
  287.                                 ODFacet*        facet,
  288.                                 ODEventData*    event,
  289.                                 ODEventInfo*    eventInfo );
  290.  
  291.     ODBoolean    HandleSelection( Environment*    ev,
  292.                                 ODFacet*        facet,
  293.                                 ODEventData*    event,
  294.                                 ODEventInfo*    eventInfo );
  295.                                 
  296.     ODBoolean    HandleMouseDownInEmbeddedFrame( Environment*    ev,
  297.                                 ODFacet*        facet,
  298.                                 ODEventData*    event,
  299.                                 ODEventInfo*    eventInfo );
  300.  
  301.     ODBoolean    HandleMouseDownInEmbeddedFrameBorder( Environment*    ev,
  302.                                                 ODFacet*        facet,
  303.                                                 ODEventData*    event,
  304.                                                 ODEventInfo*    eventInfo );
  305.  
  306.     ODBoolean    HandleMouseUpActivate( Environment*    ev, ODFacet* facet);
  307.  
  308.  
  309.     // -- Dialogs --
  310.     ODBoolean    PrepareForDialog( Environment* ev, ODFrame* frame );
  311.     void        DoneWithDialog( Environment* ev, ODFrame* frame );
  312.     void        DoDialogBox(Environment* ev, ODFrame* frame,
  313.                                           ODSShort dialogID, ODUShort errorNumber = 0);
  314.     
  315.     // -- Imaging --
  316.     
  317.     void        DrawIconView(Environment* ev, ODFacet* facet);
  318.     void        DrawThumbnailView(Environment* ev, ODFacet* facet);
  319.     void        GenerateThumbnail( Environment*    ev, ODFrame* frame );
  320.     void        DrawFrameView(Environment* ev, ODFacet* facet, ODShape* invalidShape);
  321.     void        DrawGrid(Environment* ev, ODFrame* frame);
  322.     
  323.     // -- Activation --
  324.     
  325.     ODBoolean    ActivateFrame(Environment* ev, ODFrame* frame);
  326.     void        WindowActivating(Environment* ev, ODFrame* frame,
  327.                                         ODBoolean activating);
  328.     
  329.     // -- Layout --
  330.     
  331.     ODWindow*    CreateWindow(Environment* ev, ODFrame* frame, ODType frameType,
  332.                                         WindowProperties* windowProperties);
  333.     void        CleanupWindow(Environment* ev, ODFrame* frame);
  334.     WindowProperties*    GetDefaultWindowProperties( Environment*     ev,
  335.                                                     ODFrame*        sourceFrame,
  336.                                                     Rect*            windowRect );
  337.     WindowProperties*    GetSavedWindowProperties(Environment* ev, ODFrame* frame);
  338.     Rect        CalcPartWindowSize(Environment* ev, ODFrame* sourceFrame);
  339.     Rect        CalcPartWindowPosition(Environment* ev, ODFrame* frame,
  340.                                         Rect* partWindowBounds);
  341.     ODFacet*    GetActiveFacetForFrame(Environment* ev, ODFrame* frame);
  342.     ODShape*    CalcNewUsedShape(Environment* ev, ODFrame* frame);
  343.     void        UpdateFrame(Environment* ev, ODFrame* frame, ODTypeToken view,
  344.                                         ODShape* usedShape);
  345.     void        CleanupDisplayFrame(Environment* ev, ODFrame* frame,
  346.                                         ODBoolean frameRemoved);
  347.  
  348.     // -- Clipboard --
  349.     ODBoolean     DoCutCopy(Environment* ev, ODCommandID commandID, ODFrame* frame);
  350.     ODBoolean     DoPaste(Environment* ev, ODFrame* frame);
  351.     ODBoolean     DoPasteAs(Environment* ev, ODFrame* frame, ODFacet* facet);
  352.     ODBoolean     DoClear(Environment* ev, ODFrame* frame);
  353. public: 
  354.  
  355.     // -- Content --
  356.     CShape*        CreateShape(Environment* ev, 
  357.                             ODSShort shapeType, 
  358.                             Rect shapeBounds = gGlobals->fZeroRect);
  359.                             
  360.     void        AddShape(Environment* ev, CShape* shape);
  361.     void        RemoveShape(Environment* ev, CShape* shape);
  362.     CShape*        WhichShape(Environment *ev, Point& where);
  363.     void        InvalidateShape(Environment* ev, CShape* shape);
  364.     
  365.     void        MoveShapeBefore(Environment* ev, CShape* moveShape, CShape* before);
  366.     void        MoveShapeAfter(Environment* ev, CShape* moveSshape, CShape* after);
  367.     
  368.     void         DoOpen(Environment* ev, ODFrame* frame);
  369.     
  370.     void AddSubscribeLink(CSubscribeLink* link);
  371.  
  372.     void RemoveSubscribeLink(CSubscribeLink* link);
  373.  
  374.     COrderedList* GetSubscribeLinks();
  375.  
  376.     COrderedList* GetPublishLinks();
  377.     void ContentUpdated(Environment* ev, ODUpdateID id);
  378.  
  379.     void LinkUpdated(Environment* ev, ODLink* odLink, ODUpdateID updateID);
  380.     CSelection* GetSelection();
  381.  
  382.     CPublishLink* GetPendingPublish();
  383.     void EditInLink(Environment* ev, CSubscribeLink* link);
  384.  
  385.     void LinkStatusChanged(Environment* ev, ODFrame* frame);
  386.     void ShowCantEditDialog(Environment* ev);
  387.  
  388.     ODBoolean EditInLinkAttempted(Environment* ev, ODFrame* frame);
  389.  
  390.     void RevealLink(Environment* ev, ODLinkSource* linkSource);
  391.     CPublishLink* GetPendingDragPublish();
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.     
  399.     //========================
  400.     private:
  401.  
  402.     // Since we are lazily internalizing display frames, 
  403.     // this is actually a list of CDisplayFrameProxy
  404.     // objects, rather than ODFrames.
  405.     COrderedList*        fDisplayFrameProxies;
  406.     
  407.     ODBoolean            fDirty;
  408.     ODPart*                fSelf;
  409.     ODBoolean            fReadOnlyStorage;
  410.     ODLinkStatus        fLinkStatus;
  411.     
  412.     
  413.     // Content data
  414.     ODULong                fGroupCount;
  415.     CSelection*         fSelection;
  416.     COrderedList*        fShapeList;
  417.     
  418.     ODFacet*            fHilightedDragFacet;
  419.     ODShape*            fActiveBorderShape;
  420.     
  421.     COrderedList*         fEmbeddedFrames;
  422.     
  423.     CPublishLink*        fPendingPublish;
  424.     CPublishLink*        fPendingDragPublish;
  425.     
  426.     // Ref to lists in fPartContent retained for convenience
  427.     COrderedList*          fPublishLinks; 
  428.     COrderedList*          fSubscribeLinks;  
  429.     
  430.     CPartContent*         fPartContent;
  431.     
  432.  
  433. };
  434.  
  435.  
  436. #endif